package org.bigtree.example.model.form;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import org.bigtree.example.common.frame.annotations.EnumValidate;
import org.bigtree.example.constans.GenderEnum;
import org.bigtree.example.entity.Employ;
import org.springframework.beans.BeanUtils;

import java.time.LocalDate;

/**
 * @author bigTree
 * @since 2025/4/26
 */
public record EmployForm(@NotBlank @Size(min = 2) String name,
                         @EnumValidate(enumClass = GenderEnum.class) GenderEnum gender,
                         Integer salary,
                         @NotBlank String address,
                         @NotNull LocalDate birthday,
                         @NotNull Integer deptId){

    public Employ toEntity() {
        Employ employ = new Employ();
        BeanUtils.copyProperties(this, employ);
        return employ;
    }

}